<?php

class Default_Bootstrap extends Zend_Application_Module_Bootstrap
{

    protected function _initRouter ()
    {
        $router = Zend_Controller_Front::getInstance()->getRouter();
        
        /* Rewrite : http://localhost/zend/kidshop/product
         * to : http://localhost/zend/kidshop/sanpham
        * */
        $route = new Zend_Controller_Router_Route('sanpham/*',
        		array(
        				'module' => 'default',
        				'controller' => 'product',
        				'action' => 'index'
        		)
        );
        $router->addRoute('sanpham', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/product/girls
         * to : http://localhost/zend/kidshop/sanpham/betrai
        * */
        $route = new Zend_Controller_Router_Route('sanpham/betrai/*',
        		array(
        				'module' => 'default',
        				'controller' => 'product',
        				'action' => 'boys'
        		)
        );
        $router->addRoute('betrai', $route);
        /* Rewrite : http://localhost/zend/kidshop/product/girls
         * to : http://localhost/zend/kidshop/sanpham/betrai
        * */
        $route = new Zend_Controller_Router_Route('sanpham/betrai/:page',
        		array(
        				'module' => 'default',
        				'controller' => 'product',
        				'action' => 'boys'
        		)
        );
        $router->addRoute('phantrangboy', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/product/boys
         * to : http://localhost/zend/kidshop/sanpham/begai
        * */
        $route = new Zend_Controller_Router_Route('sanpham/begai',
        		array(
        				'module' => 'default',
        				'controller' => 'product',
        				'action' => 'girls'
        		)
        );
        $router->addRoute('begai', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/product/boys
         * to : http://localhost/zend/kidshop/sanpham/timkiem/:kw
        * */
        $route = new Zend_Controller_Router_Route('sanpham/timkiem',
        		array(
        				'module' => 'default',
        				'controller' => 'product',
        				'action' => 'search'
        		)
        );
        $router->addRoute('timkiem', $route);
        
        
        /* Rewrite : http://localhost/zend/kidshop/cart
         * to : http://localhost/zend/kidshop/giohang
        * */
        $route = new Zend_Controller_Router_Route('giohang/*',
        		array(
        				'module' => 'default',
        				'controller' => 'cart',
        				'action' => 'index'
        		)
        );
        $router->addRoute('giohang', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/cart/add/id/1
         * to : http://localhost/zend/kidshop/giohang/mua/1
        * */
        $route = new Zend_Controller_Router_Route('giohang/mua/:id/:num',
        		array(
        				'module' => 'default',
        				'controller' => 'cart',
        				'action' => 'add'
        		),
        		array(
        				'id' => '(\d+)',
        		        'num' => '(\d+)'
        		)
        );
        $router->addRoute('mua', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/cart/count-item/id/1/num/2
         * to : http://localhost/zend/kidshop/giohang/resize/4/1
        * */
        $route = new Zend_Controller_Router_Route('giohang/resize/:id/:num',
        		array(
        				'module' => 'default',
        				'controller' => 'cart',
        				'action' => 'count-item'
        		),
        		array(
        				'id' => '(\d+)',
        				'num' => '(\d+)'
        		)
        );
        $router->addRoute('mua', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/users/index
         * to : http://localhost/zend/kidshop/khachhang
        * */
        $route = new Zend_Controller_Router_Route('khachhang/*',
        		array(
        				'module' => 'default',
        				'controller' => 'users',
        				'action' => 'index'
        		)
        );
        $router->addRoute('khachhang', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/users/favorite
         * to : http://localhost/zend/kidshop/uathich
        * */
        $route = new Zend_Controller_Router_Route('khachhang/uathich/*',
        		array(
        				'module' => 'default',
        				'controller' => 'users',
        				'action' => 'favorite'
        		)
        );
        $router->addRoute('uathich', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/users/like/id/44
         * to : http://localhost/zend/kidshop/khachhang/thich/:id
        * */
        $route = new Zend_Controller_Router_Route('khachhang/thich/:id',
        		array(
        				'module' => 'default',
        				'controller' => 'users',
        				'action' => 'like'
        		),
               array(
                       ':id' => "(\d+)"
                )
        );
        $router->addRoute('like', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/users/dislike/id/44
         * to : http://localhost/zend/kidshop/khachhang/khonthich/:id
        * */
        $route = new Zend_Controller_Router_Route('khachhang/khongthich/:id',
        		array(
        				'module' => 'default',
        				'controller' => 'users',
        				'action' => 'dislike'
        		),
               array(
                       ':id' => "(\d+)"
                )
        );
        $router->addRoute('dislike', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/users/history
         * to : http://localhost/zend/kidshop/khachhang/hoadon
        * */
        $route = new Zend_Controller_Router_Route('khachhang/hoadon/*',
        		array(
        				'module' => 'default',
        				'controller' => 'users',
        				'action' => 'history'
        		)
        );
        $router->addRoute('hoadon', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/users/detail-order/id/44
         * to : http://localhost/zend/kidshop/khachhang/hoadon/:id
        * */
        $route = new Zend_Controller_Router_Route('khachhang/hoadon/:id',
        		array(
        				'module' => 'default',
        				'controller' => 'users',
        				'action' => 'detail-order'
        		),
               array(
                       ':id' => "(\d+)"
                )
        );
        $router->addRoute('chitiethoadon', $route);
        
        /* Rewrite : http://localhost/zend/kidshop/cart/remove/id/1
         * to : http://localhost/zend/kidshop/giohang/xoa/1
        * */
        $route = new Zend_Controller_Router_Route('giohang/xoa/:id',
        		array(
        				'module' => 'default',
        				'controller' => 'cart',
        				'action' => 'remove'
        		),
        		array(
        				'id' => '(\d+)'
        		)
        );
        $router->addRoute('xoa', $route);
        
        
        /* Rewrite : http://localhost/zend/kidshop/product/detail/id/1 
         * to : http://localhost/zend/kidshop/sanpham/view/1.html
         * */
        $route = new Zend_Controller_Router_Route('sanpham/xem/:id', 
                array(
                        'module' => 'default',
                        'controller' => 'product',
                        'action' => 'detail'
                ),
                array(
                     'id' => '(\d+).html$'
                )
                );
        $router->addRoute('chitietsanpham', $route);
 
    }
}

